'use strict';

const Controller = require('egg').Controller;
class setAllCheckedController extends Controller {
  async index() {
    const { ctx } = this;
    var {checked} = ctx.request.body
    var data = await this.ctx.model.User.find({},{cartList:1})
    var cartList = data[0].cartList
    cartList.forEach(item=>{
        item.checked = checked
    })
    await ctx.model.User.updateOne({},{cartList})
    ctx.body ={
      code:200,
      msg:'设置购物车全选反选成功'
    }
  }
}
module.exports = setAllCheckedController;